package com.wxap;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class WXNotifyPostData {
/**
 * <OpenId><![CDATA[111222]]></OpenId>
<AppId><![CDATA[wwwwb4f85f3a797777]]></AppId>
<IsSubscribe>1</IsSubscribe>
<TimeStamp> 1369743511</TimeStamp>
<NonceStr><![CDATA[jALldRTHAFd5Tgs5]]></NonceStr>
<AppSignature><![CDATA[bafe07f060f22dcda0bfdb4b5ff756f973aecffa]]>
</AppSignature>
<SignMethod><![CDATA[sha1]]></ SignMethod >
 */
	
	private String OpenId ;
	private String AppId ;
	private String IsSubscribe;
	private String TimeStamp;
	private String NonceStr ;
	private String AppSignature ;
	private String SignMethod ;
	
	

	public String getOpenId() {
		return OpenId;
	}

	public void setOpenId(String openId) {
		OpenId = openId;
	}

	public String getAppId() {
		return AppId;
	}

	public void setAppId(String appId) {
		AppId = appId;
	}

	public String getIsSubscribe() {
		return IsSubscribe;
	}

	public void setIsSubscribe(String isSubscribe) {
		IsSubscribe = isSubscribe;
	}

	public String getTimeStamp() {
		return TimeStamp;
	}

	public void setTimeStamp(String timeStamp) {
		TimeStamp = timeStamp;
	}

	public String getNonceStr() {
		return NonceStr;
	}

	public void setNonceStr(String nonceStr) {
		NonceStr = nonceStr;
	}

	public String getAppSignature() {
		return AppSignature;
	}

	public void setAppSignature(String appSignature) {
		AppSignature = appSignature;
	}

	public String getSignMethod() {
		return SignMethod;
	}

	public void setSignMethod(String signMethod) {
		SignMethod = signMethod;
	}

	public static WXNotifyPostData parseFromStr(String str){
//		str = str.replaceAll("<xml>", "");
//		str = str.replaceAll("</xml>", "");
		System.out.println(str);
		XStream xstream = new XStream(new DomDriver());
		xstream.alias("xml", WXNotifyPostData.class);
		return (WXNotifyPostData) xstream.fromXML(str);
	}
	
	public static void main(String[] args){
		String xml = "<xml><OpenId><![CDATA[oBbEguL0q17dyh6SpRvq3xLrDRx0]]></OpenId>\n<AppId><![CDATA[wx4786e32f1967c6b2]]></AppId>\n<IsSubscribe>1</IsSubscribe>\n<TimeStamp>1407232523</TimeStamp>\n<NonceStr><![CDATA[7m98DGfWFVAp0mV4]]></NonceStr>\n<AppSignature><![CDATA[a1757eecfa0d202ff4a111b676546dbf7f212e3a]]></AppSignature>\n<SignMethod><![CDATA[sha1]]></SignMethod>\n</xml>";
		
		System.out.println(ToStringBuilder.reflectionToString(parseFromStr(xml)));
	}
}
